<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<title></title>
<link rel="stylesheet" href="/Public/css/pintuer.css">
<link rel="stylesheet" href="/Public/css/admin.css">
<script src="/Public/js/jquery.js"></script>
<script src="/Public/js/pintuer.js"></script>
<script type="text/javascript" src="/Public/layer/layer.js"></script>
</head>
<body>
<div class="panel admin-panel">
  <div class="panel-head"><strong class="icon-reorder"> 景点列表</strong></div>
  <div class="padding border-bottom">  
    <a class="button border-yellow" href="<?php echo U('Admin/addSights');?>" target="right"><span class="icon-plus-square-o"></span> 添加景点</a>
  </div>
  <table class="table table-hover text-center">
    <tr>
      <th width="10%">ID</th>
      <th width="10%">地点</th>
      <th width="15%">图片1</th>
      <th width="10%">图片2</th>
      <th width="10%">正文</th>
      <th width="10%">热度</th>
      <th width="10%">时间</th>
      <th width="25%">操作</th>
    </tr>
    <?php if(is_array($data)): $i = 0; $__LIST__ = $data;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vol): $mod = ($i % 2 );++$i;?><tr>
        <td><?php echo ($vol["id"]); ?></td>
        <td><?php echo ($vol["title"]); ?></td>     
        <td><img src="<?php echo ($vol["img1"]); ?>" alt="" width="120" height="50" /></td>   
        <td><img src="<?php echo ($vol["img1"]); ?>" alt="" width="120" height="50" /></td>   
        <td>
            <?php echo (msubstr($vol["sights_text"],0,20)); ?>
            <a class="show"  href="javascript:;" data="<?php echo ($vol["id"]); ?>" data-title="<?php echo ($vol["title"]); ?>" style="color:red;"><span class="icon-edit"></span> 查看详情</a>
        </td>
        <td><?php echo ($vol["hot"]); ?></td>
        <td><?php echo (date('Y-m-d',$vol["time"])); ?></td>
        <td>
          <div class="button-group">
            <a class="button border-main" href="/index.php/Home/Admin/editSights/id/<?php echo ($vol["id"]); ?>"><span class="icon-edit"></span> 编辑</a>
            <a class="button border-red" onclick="del(this)" id="<?php echo ($vol["id"]); ?>"><span class="icon-trash-o"></span> 删除</a>
          </div>
        </td>
      </tr><?php endforeach; endif; else: echo "" ;endif; ?>
    
  </table>
  <div class="pagelist"><?php echo ($show); ?></div>
</div>
<script type="text/javascript">
    function del(obj){
      var res = confirm("您确定要删除吗?");
      if(res == true){
        var id = obj.id;
        $.post('/index.php/Home/Admin/sightsdel/id/'+id,function(data){
          console.log(data);
          if(data == 1){
            alert('删除成功！');
            window.location.reload();
          }else{
            alert('删除失败！');
            window.location.reload();
          }   
        },'json'); 
      }
    }
    $(function(){
        $('.show').on('click',function(){
            var id = $(this).attr('data');
            var title = $(this).attr('data-title');
            console.log(id,title);
            layer.open({
              type: 2,
              title: title,
              shadeClose: true,
              shade: 0.3,
              area: ['380px', '90%'],
              content: '/index.php/Home/Admin/showSights/id/' + id //iframe的url
            });
        });
    });
</script>
</body></html>